import request from '@/utils/request';
import { download, toFormData, checkDownloadRes } from '@/utils/common';

/**
 * 分页查询团队分析
 */
export async function pageEtpOrganizationStatss(params) {
  const res = await request.get('/etp/etpOrganizationStats/list', { params });
  if (res.data.code === 200) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 查询全部团队分析
 */
export async function listEtpOrganizationStatss(params) {
  const res = await request.get('/etp/etpOrganizationStats/list', { params });
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 根据id查询团队分析
 */
export async function getEtpOrganizationStats(id) {
  const res = await request.get('/etp/etpOrganizationStats/' + id);
  if (res.data.code === 200) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 添加团队分析
 */
export async function addEtpOrganizationStats(data) {
  const res = await request.post('/etp/etpOrganizationStats', data);
  if (res.data.code === 200) {
    return res.data.msg;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 修改团队分析
 */
export async function updateEtpOrganizationStats(data) {
  const res = await request.put('/etp/etpOrganizationStats', data);
  if (res.data.code === 200) {
    return res.data.msg;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 删除团队分析
 */
export async function removeEtpOrganizationStats(id) {
  const res = await request.delete('/etp/etpOrganizationStats/' + id);
  if (res.data.code === 200) {
    return res.data.msg;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 批量删除团队分析
 */
export async function removeEtpOrganizationStatss(ids) {
  const res = await request.delete('/etp/etpOrganizationStats/' + ids.join());
  if (res.data.code === 200) {
    return res.data.msg;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 导出团队分析
 */
export async function exportEtpOrganizationStatss(params) {
  const res = await request({
    url: '/etp/etpOrganizationStats/export',
    method: 'POST',
    data: toFormData(params),
    responseType: 'blob'
  });
  await checkDownloadRes(res);
  download(res.data, `etpOrganizationStats_${Date.now()}.xlsx`);
}
